package mainPackage;

import java.io.*;
import java.util.*;

public class FileWork {
    public static void write(String fileName, String text1, String text2, String text3) throws FileNotFoundException {
        PrintWriter writer = new PrintWriter(new File(fileName).getAbsoluteFile());
        writer.println(text1);
        writer.println(text2);
        writer.println(text3);
        writer.close();
    }

    public static int[] read (String fileName) throws FileNotFoundException {
        ArrayList<String> list = new ArrayList<String>();
        Scanner scan = new Scanner(new File(fileName));
        int k = 0;
        while(scan.hasNext()) {
            list.add(k, scan.nextLine() + "\r\n");
            k++;
        }
        scan.close();

        int[] mass = new int[list.size()];
        for (int i=0; i<list.size(); i++)
            mass[i] = Integer.parseInt(list.get(i).split(" ")[1]);

        return mass;
    }

    public static boolean delete(String fileName) throws FileNotFoundException {
        File file = new File(fileName);
        return file.delete();
    }
}
